<!DOCTYPE html>
<title>bugLink</title>
<meta charset="utf-8">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="../chops-bug-link.html">

<test-fixture id="chops-bug-link-test">
  <template>
    <chops-bug-link></chops-bug-link>
  </template>
</test-fixture>

<script>
  'use strict';

  suite('chops-bug-link', function() {
    let element;
    setup(function() {
      element = fixture('chops-bug-link-test');
    });

    test('compute bugId', function(done) {
      element.bug = 'crbug.com/id=1344928#somecomment=c1234';
      assert.equal(1344928, element.bugId);

      element.bug = 'crbug/1344928';
      assert.equal(1344928, element.bugId);

      element.bug = '1344928';
      assert.equal(1344928, element.bugId);

      element.bug = 'bad but link';
      assert.equal('Unknown', element.bugId);

      done();
    });

    test('compute bugName', function(done) {
      element.bug = 'crbug/1234';
      assert.equal('chromium', element.bugProject);

      element.bug = 'https://bugs.chromium.org/p/monorail/issues/detail?id=1543';
      assert.equal('monorail', element.bugProject);

      element.bug = 'gerrit:10384';
      assert.equal('gerrit', element.bugProject);

      done();
    });

  });
</script>
